class Section < ActiveRecord::Base
	has_many :pages
	validates_presence_of :name
	
	def home_page
		self.pages.find(:first, :conditions => ["section_id = ? and home = true", self.id])
	end
	
	def section_pages
		self.pages.find(:all, :conditions => ["section_id = ? and home = false", self.id])
	end
	
	def self.main
	  @sections = self.find(:all)
	  @sections.delete(Section.find_by_name("news"))
	  @sections
	end
end
